
<%@ page pageEncoding="UTF-8" isELIgnored="false" %>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台列表页面</title>
    <link rel="stylesheet" href="../static/css/bootstrap.min.css"/>
    <script src="../static/js/jquery-3.5.1.min.js"></script>
    <script>
        $(function (){
            $.post("${pageContext.request.contextPath}/menu/queryAll",function (menuList){
                //console.log(menuList);
                $.each(menuList,function (index,menu){
                    //console.log(menu);

                    $("#menuTable").append("" +
                        "<tr>" +
                            "<th scope='row'>1</th>" +
                            "<td>"+menu.name+"</td>" +
                            "<td><img style='width: 200px;height: 120px;' src='../static/imgs/"+menu.photo+"' class='img-thumbnail' ></td>" +
                            "<td>"+menu.createDate+"</td>" +
                            "<td>"+menu.createPerson+"</td>" +
                            "<td>"+menu.digest+"</td>" +
                            "<td>"+menu.step+"</td>" +
                            "<td>" +
                                "<a href='' class='btn btn-danger'>删除</a>&nbsp;&nbsp;" +
                                "<a href='./update.html' class='btn btn-info'>修改</a>" +
                            "</td>" +
                        "</tr>");
                })
            })

            //点击清空索引
            $("#clearIndex").click(function (){
                $.post("${pageContext.request.contextPath}/menu/clearIndex",function (data){
                    alert("索引已清空");
                })
            })

            //重构索引
            $("#addIndex").click(function (){
                $.post("${pageContext.request.contextPath}/menu/addIndex",function (data){
                    alert("索引已重构");
                })
            })
        });
    </script>
</head>
<body>

<!--功能按钮-->
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">后台食谱管理系统</a>
        </div>

        <!--功能按钮 -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <form class="navbar-form navbar-left">
                <button id="clearIndex" type="button" class="btn btn-danger">清空ES索引库</button>
                <button id="addIndex"  type="button" class="btn btn-info">基于mysql数据重建索引</button>
            </form>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#"><span class="text-info">小陈</span></a></li>
                <li><a href="#">退出系统</a></li>
            </ul>
        </div>
    </div>
</nav>

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-12">
            <a href="./add.html" class="btn btn-info">添加</a>
        </div>
    </div>
    <div class="row" style="margin-top: 20px;">
        <div class="col-sm-12">
            <table class="table table-bordered" id="menuTable">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>菜谱名称</th>
                        <th>图片</th>
                        <th>录入时间</th>
                        <th>录入人</th>
                        <th>关于摘要</th>
                        <th>步骤摘要</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                <%--<tr>
                    <th scope="row">1</th>
                    <td>西红柿炒蛋</td>
                    <td><img style="width: 200px;height: 120px;" src="../static/imgs/1.jpg" class="img-thumbnail" alt=""></td>
                    <td>2012-12-12</td>
                    <td>小陈</td>
                    <td>西红柿炒鸡蛋，又名番茄炒蛋，..</td>
                    <td>1.将鸡蛋打入碗中，快速搅匀....</td>
                    <td><a href="" class="btn btn-danger">删除</a>&nbsp;&nbsp;<a href="./update.html" class="btn btn-info">修改</a></td>
                </tr>--%>
                </tbody>
            </table>
        </div>
    </div>

    <!--热词处理-->

</div>


</body>
</html>